﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Data.GameData.Interfaces;

namespace GameFramework
{
    public static class MovementManager
    {
        private static readonly int[] pulseTable =
        {
            0,0,1,1,1,1,
            0,1,0,1,1,1,
            1,0,1,0,1,1,
            0,1,0,1,1,1,
            0,0,1,1,1,1,
            0,0,0,0,0,1
        };

        /// <summary>
        /// Determine the number of hexes a unit can move in a single strategic pulse
        /// </summary>
        /// <param name="pulse">The current movement pulse</param>
        /// <param name="unit">The unit moving</param>
        /// <returns>The number of hexes to move</returns>
        public static int HexesToMove(int pulse, IFleetElement unit)
        {
            int speed = unit.BestSpeed % 6;
            int multiplier = (int)unit.BestSpeed / 6;
            int index = (6 * (pulse - 1)) + speed - 1;

            return pulseTable[index] + (1 * multiplier);
        }
    }
}
